import networkx as nx
import matplotlib.pyplot as plt

# 创建一个空的无向图
G = nx.Graph()

# 添加4个顶点
G.add_nodes_from([1, 2, 3, 4])

# 添加5条边
G.add_edges_from([(1, 2), (1, 3), (2, 3), (3, 4), (4, 1)])

# 绘制图形
plt.figure(figsize=(8, 6))  # 设置图形大小
nx.draw(G, with_labels=True, node_size=500, node_color='lightblue', font_size=16, font_weight='bold')
plt.title("无向社交网络图 (4个顶点, 5条边)", fontsize=16)
plt.show()
